package com.spt.springbootzhsx.service;

import com.spt.springbootzhsx.entity.Cinema;
import com.spt.springbootzhsx.mapper.CinemaMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class CinemaImpl implements CinemasService{
    @Autowired
    private CinemaMapper cinemaMapper;


    @Override
    public int getCinemaCount() {
        ArrayList<Cinema> list=cinemaMapper.getAllCinema();
        return list.size();
    }

    @Override
    public ArrayList<Cinema> getAllCinema() {
        ArrayList<Cinema> list=cinemaMapper.getAllCinema();
        return list;
    }

    @Override
    public Cinema getCinemaByCname(String cname) {
        Cinema cinema=cinemaMapper.getCinemaByCname(cname);
        return cinema;
    }

    @Override
    public Cinema getCinemaByCid(Integer cid) {
        Cinema cinema=cinemaMapper.getCinemaByCid(cid);
        return cinema;
    }

    @Override
    public String updateCinema(Cinema cinema) {
        int k=cinemaMapper.updateCinema(cinema);
        if(k>=1){
            return "放映厅更新成功！";
        }else{
            return "放映厅更新失败！";
        }
    }

    @Override
    public String deleteCinema(Integer cid) {
        int k=cinemaMapper.deleteCinema(cid);
        if(k>=1){
            return "放映厅删除成功！";
        }else{
            return "放映厅删除失败！";
        }
    }

    @Override
    public String addCinema(Cinema cinema) {
        int k=cinemaMapper.addCinema(cinema);
        if(k>=1){
            return "放映厅添加成功！";
        }else{
            return "放映厅添加失败！";
        }
    }
}
